/**
 * *****************************************************************
 * @file    adt3102_dsp.h
 * @author  WuHao(hwu@andartechs.com.cn)
 * @version 1.0.0
 * @date    2020-11-09
 * @brief
 *
 *                 Copyright (c) 2020, Andar Technologies Inc.
 *                           www.andartechs.com 
 *
 * *****************************************************************
 */
#ifndef __DSP_H
#define __DSP_H
/*------------------------------ include -------------------------------------*/
#include "adt3102_type_define.h"
#include "adt3102.h" 

/*------------------------------ variable ------------------------------------*/
extern volatile int32 v_g_fftFlag;
/*------------------------------ function ------------------------------------*/
/**
 * @brief   ADT301 ASIC FFT.
 *          |   1   2 3 4 5..........................................fftLen|
            srcAddr
 * @param   fftLen: fft points.
 * @param   srcAddr:fft source data first address.
 * @param   srcStep:fft source data step.
 * @param   dstStep:fft destination data step.
 * @return  None.
 * @note
 */
void fftSingle(int32 fftLen, uint32 srcAddr, uint32 dstAddr, uint16 srcStep, uint16 dstStep);

/**
 * @brief   Energy merging after FFT.
 * @param   None.
 * @return  None.
 * @note
 */
void absAdt3102(uint16 fftLen ,uint16 rngMax ,uint32 srcAddr,uint32 dstAddr);

/**
 * @brief   ADT301 ASIC FFT.
 * srcAddr |11 12 13 14 15..........................................1(fftLen) |
 *      |21 22 23 24 25..........................................2(fftLen) |
 *      |31 32 33 34 35..........................................3(fftLen) |
 *      |..................................................................|
 *      |..................................................................|
 *      |..................................................................|
 *      |..................................................................|
 *      |..................................................................|
 *      |(countFft)1 (countFft)2 (countFft)3.............(countFft)(fftLen)|
 * @param   fftLen:.
 * @param   srcAddr:.
 * @param   srcStep:.
 * @param   dstStep:.
 * @return  None.
 * @note
 */
void fftProcess(int32 fftLen, int32 fftChirpNum, uint32 srcAddr, uint32 dstAddr, uint16 srcStep, uint16 dstStep);

/**
 * @brief   Do two-dimensional FFT.
 * @param   dopFftLen: doppler fft points.
 * @param   rngMax: maximum on range dimension.
 * @param   srcAddr: doppler fft source data first address.
 * @param   dstAddr: doppler fft destination data first address.
 * @param   srcStep: doppler fft source data step.
 * @param   dstStep: doppler fft destination data step.
 * @return  None.
 * @note
 */
void velocityFftProcess(int32 dopFftLen, int32 rngMax, uint32 srcAddr, uint32 dstAddr, uint16 srcStep, uint16 dstStep);

/**
 * @brief   serach for single peak.
 * @param   dopFftLen: doppler fft points.
 * @param   rngMax: maximum on range dimension.
 * @param   absMergeArray: An array that holds energy vals.
 * @return  None.
 * @note
 */
void dopplerSwap(int32 dopFftLen, int32 rngMax, uint32 absMergeArray[][CHIRP_NUM]);

/**
 * @brief   velocity hanning window process by software
        |   1   2 3 4 5..........................................fftLen|
        srcAddr.
 * @param   fftLen: fft length <=64.
 * @param   srcAddr: .
 * @param   srcStep: .
 * @param   wnIdxStep: window table index step.
 * @return  None.
 * @note
 */
void velFftWn(int32 fftLen, uint32 srcAddr, uint16 srcStep, uint16 wnIdxStep);

#endif




